#include "test_config_Arg.h"



#ifdef TEST_DENIS_ARG_USE

#define TEST_DENIS_ARG_USE1
#define TEST_DENIS_ARG_USE2
#define TEST_DENIS_ARG_USE3
#define TEST_DENIS_ARG_USE4

namespace
{
    int ViewTest(Arg a1, Arg a2=SEmpty(), Arg a3=SEmpty(), Arg a4 = SEmpty())
    {
        (void) a4;
        FOR_TESTING(std::cout<< "int ViewTest(): BEGIN\n"); //const SEmpty& empty = a4;
        const bool fSuccess1 = a1.Check<int>(); const int r1 = (fSuccess1)? (const int&) a1:0;
        const bool fSuccess2 = a2.Check<int>(); const int r2 = (fSuccess2)? (const int&) a2:0;
        const bool fSuccess3 = a3.Check<int>(); const int r3 = (fSuccess3)? (const int&) a3:0;
        FOR_TESTING(std::cout<< "int ViewTest(): ENDED\n");
        return r1+r2+r3;
    }

    int CViewTest(const Arg a1, const Arg a2=SEmpty(),
                  const Arg a3=SEmpty(), const Arg a4=SEmpty())
    {
        (void) a4;
        FOR_TESTING(std::cout<< "int CViewTest(): BEGIN\n");
        const bool fSuccess1 = a1.Check<int>(); const int r1 = (fSuccess1)? (const int&) a1:0;
        const bool fSuccess2 = a2.Check<int>(); const int r2 = (fSuccess2)? (const int&) a2:0;
        const bool fSuccess3 = a3.Check<int>(); const int r3 = (fSuccess3)? (const int&) a3:0;
        FOR_TESTING(std::cout<< "int CViewTest(): ENDED\n");
        return r1+r2+r3;
    }

    int CRViewTest(const Arg& a1, const Arg& a2=SEmpty(),
                   const Arg& a3=SEmpty(), const Arg& a4=SEmpty())
    {
        (void) a4;
        FOR_TESTING(std::cout<< "int CRViewTest(): BEGIN\n");
        const bool fSuccess1 = a1.Check<const int>(); const int r1 = (fSuccess1)? (const int&) a1:0;
        const bool fSuccess2 = a2.Check<const int>(); const int r2 = (fSuccess2)? (const int&) a2:0;
        const bool fSuccess3 = a3.Check<const int>(); const int r3 = (fSuccess3)? (const int&) a3:0;
        FOR_TESTING(std::cout<< "int CRViewTest(): ENDED\n");
        return r1+r2+r3;
    }


    struct Crolik
    {
        Crolik(const int val=0):mVal(1)
        {
            if(val==0) { FOR_TESTING(std::cout<<"Crolik::CTOR\n"); }
            else { FOR_TESTING(std::cout<<" TEMPORARY Crolik::CTOR\n"); }
        }

       ~Crolik(){ FOR_TESTING(std::cout<<"Crolik::DTOR\n"); mVal=0; }
        int mVal;
    };

    int GetInt()     { return int(1); }
    Crolik GetCrol() { return Crolik(1); }

    int ViewCrol(const Arg& a1, const Arg& a2=SEmpty(),
                   const Arg& a3=SEmpty(), const Arg& a4=SEmpty())
    {
        (void) a4;  int val=0;
        FOR_TESTING(std::cout<< "int ViewCrol(): BEGIN\n");
        const bool fSuccess1 = a1.Check<const Crolik>();
        const bool fSuccess2 = a2.Check<const Crolik>();
        const bool fSuccess3 = a3.Check<const Crolik>();
        const bool fSuccess4 = a4.Check<const Crolik>();

        if(fSuccess1) { const Crolik& ref = a1; val += ref.mVal; }
        if(fSuccess2) { const Crolik& ref = a2; val += ref.mVal; }
        if(fSuccess3) { const Crolik& ref = a3; val += ref.mVal; }
        if(fSuccess4) { const Crolik& ref = a4; val += ref.mVal; }
        FOR_TESTING(std::cout<< "int ViewCrol(): ENDED\n");
        return val;
    }
}
// ------------------------------------------------------------------------------------------------------//
#ifdef TEST_DENIS_ARG_USE1
TEST(test_Arg, use_000)
{
    int a1=10,a2=20,a3=30;
    Endl(); const int result = ViewTest(a1,a2,a3); const int most_be = a1+a2+a3;
    EXPECT_EQ(most_be, result );
}
TEST(test_Arg, use_001)
{
    int a1=10,a3=30;
    Endl(); const int result = ViewTest(a1,20.0f,a3); const int most_be = a1+a3;
    EXPECT_EQ(most_be, result );
}

#endif
// ------------------------------------------------------------------------------------------------------//
#ifdef TEST_DENIS_ARG_USE2
TEST(test_Arg, use_002)
{
    int a1=10,a2=20,a3=30;
    Endl(); const int result = CViewTest(a1,a2,a3); const int most_be = a1+a2+a3;
    EXPECT_EQ(most_be, result );
}
TEST(test_Arg, use_003)
{
    int a1=10,a3=30;
    Endl(); const int result = CViewTest(a1,20.0f,a3); const int most_be = a1+a3;
    EXPECT_EQ(most_be, result );
}

#endif
// ------------------------------------------------------------------------------------------------------//
#ifdef TEST_DENIS_ARG_USE3
TEST(test_Arg, use_004)
{
    int a1=10,a2=20,a3=30;
    Endl(); const int result = CRViewTest(a1,a2,a3); const int most_be = a1+a2+a3;
    EXPECT_EQ(most_be, result );
}
TEST(test_Arg, use_005)
{
    int a1=10,a3=30;
    Endl(); const int result = CRViewTest(a1,20.0f,a3); const int most_be = a1+a3;
    EXPECT_EQ(most_be, result );
}
#endif
// ------------------------------------------------------------------------------------------------------//
#ifdef TEST_DENIS_ARG_USE4
TEST(test_Arg, use_006)
{
    Endl();
    const int result = CRViewTest( GetInt(),GetInt(),GetInt());
    EXPECT_EQ(3, result );
}
TEST(test_Arg, use_007)
{
    Endl();
    const int result = ViewCrol( GetCrol(),GetCrol(),GetCrol());
    EXPECT_EQ(3, result );
}

#endif
// ------------------------------------------------------------------------------------------------------//






#endif //TEST_DENIS_ARG_USE
